package com.jp.knowledge.view;

import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.ViewGroup;

/**
 * Created by 528787067@qq.com on 2017/4/5.
 */

public class HomePagerHeaderRecycerView extends RecyclerView {
    public HomePagerHeaderRecycerView(Context context) {
        super(context);
        init(context);
    }

    public HomePagerHeaderRecycerView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public HomePagerHeaderRecycerView(Context context, @Nullable AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init(context);
    }

    public HomePageView getHomePageView(){
        return this.homePageView;
    }

    private HomePageView homePageView;
    private void init(Context context){
        homePageView = new HomePageView(context);
        setHasFixedSize(true);
        setLayoutManager(new LinearLayoutManager(context));
        setAdapter(new Adapter<ViewHolder>() {
            @Override
            public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
                return new ViewHolder(homePageView){};
            }
            @Override
            public void onBindViewHolder(ViewHolder holder, int position) {}
            @Override
            public int getItemCount() {
                return 1;
            }
        });
    }
}
